#ifndef __I2C_H
#define __I2C_H
#include "sys.h"

#define I2C_PORT GPIOB         // PB
#define I2C_SCL_PIN GPIO_Pin_6 // PB6
#define I2C_SDA_PIN GPIO_Pin_7 // PB7

#define I2C_HOSTADDRESS 0xC0 // 主机地址
#define I2C_SUBSPEED 50000   // 总线速度(<400000)

void I2C_Config(void);

void I2C_WriteByte(uint8_t SlaveAddr, uint8_t RegAddr, uint8_t b);

void I2C_WriteBuffer(uint8_t SlaveAddr, uint8_t RegAddr, uint8_t *pBuf, uint16_t Size);

uint8_t I2C_ReadByte(uint8_t SlaveAddr, uint8_t RegAddr);

void I2C_ReadBuffer(uint8_t SlaveAddr, uint8_t RegAddr, uint8_t *pBuf, uint16_t Size);

#endif
